package com.suray.wcs.service.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.suray.basic.wcs.utils.IBaseEnum;

import java.io.Serializable;

public enum WmsTaskStatus implements IBaseEnum<Serializable> {

    RECEIVED(0, "已接收"),
    START(1, "任务开始"),
    TAKE_FINISH(2, "取货完成"),
    INTERRUPT(3, "任务中断"),
    PUT_FINISH(4, "放货完成"),
    FINISH(8, "任务结束"),
    EMPTY_PALLET(9, "取拖无拖"),
    CANCEL(10, "任务取消"),
    EXIST_PALLET(11, "存拖有拖");


    @EnumValue
    private int taskProgress;
    @JsonValue
    private String description;

    WmsTaskStatus(int taskProgress, String description) {
        this.taskProgress = taskProgress;
        this.description = description;
    }

    @Override
    public String toString() {
        return description;
    }

    public static WmsTaskStatus parseTaskProgress(int taskProgress) {
        WmsTaskStatus[] taskProgresses = WmsTaskStatus.values();
        for (WmsTaskStatus progress : taskProgresses) {
            if (progress.taskProgress == taskProgress) {
                return progress;
            }
        }
        throw new IllegalArgumentException("任务进度参数异常");
    }

    public static WmsTaskStatus getByTaskProgress(int taskProgress) {
        WmsTaskStatus[] taskProgresses = WmsTaskStatus.values();
        for (WmsTaskStatus progress : taskProgresses) {
            if (progress.taskProgress == taskProgress) {
                return progress;
            }
        }
        throw null;
    }

    public static WmsTaskStatus parseTaskProgress(String description) {
        WmsTaskStatus[] taskProgresses = WmsTaskStatus.values();
        for (WmsTaskStatus progress : taskProgresses) {
            if (progress.description.equals(description)) {
                return progress;
            }
        }
        throw new IllegalArgumentException("任务进度描述异常");
    }

    public int getProgressNum() {
        return taskProgress;
    }

    @Override
    public Serializable getValue() {
        return taskProgress;
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public Integer getVal() {
        // TODO Auto-generated method stub
        return null;
    }

}
